import { listen } from '@src/utils/listener'
import { setupResizeEvent } from '@src/events/resize'
import { setupTouchEvent } from '@src/events/touch'
import { setupMouseEvent } from '@src/events/mouse'

// setupEventListeners
export default function mixinEventListeners(self) {
  var option = {
    down: false,
    clickActive: true,
    lastX: 0,
    lastY: 0,
    downX: 0,
    downY: 0,
    ongoingTouches: {},
    activeTouch: null,
  }

  self.__mouseX = -1
  self.__mouseY = -1
  self.mouseCurrent = { clientX: 0, clientY: 0 }
  self.touchMode = false

  // 綁定事件 - 窗口变化
  listen(window, 'resize', () => setupResizeEvent(self))

  // 綁定事件 - 移动端 触摸
  setupTouchEvent(self, option)

  // 綁定事件 - PC端 鼠标
  setupMouseEvent(self, option)
}
